-
Notifications
You must be signed in to change notification settings - Fork 851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes the implementation of Error.captureStackTrace
so that it does not need to create new Error()
#1436
base: master
Are you sure you want to change the base?
Conversation
…es not need to create `new Error()` in order to provide the stack trace; this fixes a problem where a stack overflow can occur when the global `Error` class has been replaced, such as in the recent implementation of `core-js` polyfill (see https://github.com/zloirock/core-js)
I'm in favor of doing this. To get the tests to pass, you'll need to ensure that "./gradlew check" passes. It looks like the formatting isn't what the "spotless" tool expects, and you can fix that by first running "./gradlew spotlessApply". Thanks! |
Two other things:
|
I came across it only when a minor-version upgrade to the core-js package was installed; and the polyfill is quite convoluted and spread over a number of lines. I'm not confident it'll be at all easy to reproduce without pulling in the core-js code. OTOH the original Rhino code says that it was just trying to reuse the code from the constructor of Would you be comfortable if there was unit tests to show that it still works this way, i.e. rather than test for the stack overflow, test instead that the captureStackTrace still works as expected?
No problem, also the unit tests and formatting |
Ah - hang on, the problem would be that throwing a JavaScript error would cause the stack overflow exception; that throw should (in theory at least) never be thrown any more, but I had to add it so that I could set a breakpoint and catch the problem. Probably best if I just delete it? |
How do you debug the javascript code as it is being run by rhino? I've got "a" debugger but only one that works inside of my framework. |
Thanks for continuing to look at this. I have been able to use "normal" debuggers like the one built-in to VS Code with Rhino, but that's primarily to debug the Java code. For debugging the JavaScript directly it's a very different thing, although the debugger built in to Rhino (in the "toolsrc" directory) has given some people help in some circumstancesl. |
@johnspackman any update on this? Is there anything you need from us to move this forward? |
No update unfortunately; the issue I have is that in order to add a unit test, I'm struggling to reproduce it - what was failing for me is too big to include in a unit test, and a lack of debugger for the javascript made life hard. Although there is a debugger in toolsrc, I havn't had a chance to look at it, and AFAICR I also had issues with just running the existing unit tests. I think I ended up giving up because the simple task of "add a unit test" blew up into a large amount of work just to be able to get to the starting block, so to speak and I ran out of time |
Converted to a draft as it's missing a testcase |
This fixes a problem where a stack overflow will occur when the global
Error
class has been replaced, such as in the recent implementation ofcore-js
polyfill (see https://github.com/zloirock/core-js).Only recent revisions of
core-js
have triggered the stack overflow, and the polyfill is essential - the Qooxdoo.org project supports Rhino as a target and incorporatingcore-js
is mandatory.This change is 100% backwards compatible.